#include "VCatagoryEffectItem.h"
#include "VCatagoryEffect.h"
#include "VButton.h"
#include "VPicture.h"
#include "VMain.h"

VCatagoryEffectItem::VCatagoryEffectItem(void)
{
    init();
}

VCatagoryEffectItem::~VCatagoryEffectItem(void)
{
}

void VCatagoryEffectItem::init()
{
    _btn = new VButton;
}

bool VCatagoryEffectItem::render() const
{
    if (!VRRWidget::render())
    {
        return false;
    }

    _btn->render();
    selfRender();


    return true;
}

bool VCatagoryEffectItem::loadTexture(const std::string& imgpath)
{
    return _btn->loadTexture(imgpath);
}

bool VCatagoryEffectItem::selfRender() const
{
    int starty = _y + _h * (2.0 / 3.0);

    VMain::drawReflection(_btn->currentPicture()->getTexture(), _x, starty, _w, _h);

    return true;
}

void VCatagoryEffectItem::move(int x, int y)
{
    VWidget::move(x, y);
    _btn->move(x, y);
    _resx = x;
    _resy = y;
}

void VCatagoryEffectItem::resize(int w, int h)
{
    VWidget::resize(w, h);
    _btn->resize(w, h * (2.0 / 3.0));
    _resw = w;
    _resh = h;
}

void VCatagoryEffectItem::mouseClick(int x, int y)
{
    UNUSED(x);
    UNUSED(y);

    ((VCatagoryEffect*)(_parent->parent()))->
    clickEventHandle(
        (VCatagoryEffectRow*)_parent,
        this);
}